package cn.bugstack.springframework.beans.factory.support;

import cn.bugstack.springframework.BeanException;
import cn.bugstack.springframework.beans.factory.config.BeanDefinition;

/**
 * description: 实例化Bean
 * taskId：
 * <pre>
 * change history:
 * date             defect#             person                comments
 * ---------------------------------------------------------------------
 * 2024/12/31       ********         zhaochaoyue        create file
 * </pre>
 *
 * @author: zhaochaoyue
 * @date: 2024/12/31 15:37
 * @copyright: 2024
 */
public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFactory{

    @Override
    protected Object createBean(String name, BeanDefinition beanDefinition) throws BeanException{
        Object bean;
        try {
            bean = beanDefinition.getBeanClass().newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new BeanException("Instantiation of bean failed",e);
        }
        
        addSingleton(name,bean);
        return bean;
    }
}
